//
//  UIButton+TT.m
//  TT
//
//  Created by Lenny on 16/4/16.
//  Copyright © 2016年 Lenny. All rights reserved.
//

#import "UIButton+TT.h"

@implementation UIButton (TT)

- (void)setButtonStyleWithBtnStr:(NSString *)btnStr withOneDic:(NSDictionary *)oneDic withTwoDic:(NSDictionary *)twoDic {
    
    if (self.subviews.count > 0) {
        
        [self.subviews[0] removeFromSuperview];
    }
    UILabel *labe = [[UILabel alloc] init];
    labe.numberOfLines = 0;
    labe.textAlignment = NSTextAlignmentCenter;
    [self addSubview:labe];
    
    NSRange range = [btnStr rangeOfString:@"\n"];
    NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:btnStr];
    [attr setAttributes:oneDic range:NSMakeRange(0, range.location)];
    [attr setAttributes:twoDic range:NSMakeRange(range.location, btnStr.length - range.location)];
    labe.attributedText = attr;
    
    [labe mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.left.mas_equalTo(0);
    }];
}

@end
